
#ifndef ___GENE_INTERFACE___
#define ___GENE_INTERFACE___

#include "Entry/LibExportCom.h"
#include "Data/DataIf.h"
#include "Event/EvtIf.h"
#include "GeneCreateDataIf.h"

class IGeneHost;

//
//	Gene Interface
//	Gene is a basic function unit , which can be attached on a host object to enable host to have that function, can also 
//	be detached from its host object to disable that function.
//	Gene can also be defined as a parallel state on its host object. the host object itself act as the state machine.
//
class TCOM_API IGene
{
public:
	virtual ~IGene(){;}

	//	
	//	ID
	//
	virtual int		getID()const	= 0;	

	//
	//	Mutex Rule
	//
	virtual int		getMutexRule()const		= 0;	

	//
	//	Mutex Group
	//
	virtual int		getMutexGroup()const		= 0;

	//
	//	Time To Live (Duration)
	//
	virtual int		getDuration()const	= 0;	

	//
	//	Static Gene Data
	virtual IData*	getStaticData() = 0;

	//
	//	set gene host
	//
	virtual bool setHost(IGeneHost* pHost)	= 0;

	//
	//	invoked just after gene's construction
	//	which is used to do all the initialization
	//
	virtual bool onInit(IGeneCreateData& createData)	= 0;

	//
	//	invoked just after gene is attached on a host object
	//
	virtual bool onAttach()	= 0;
	//
	//	invoked when gene is detached from its host object
	//
	virtual bool onDetach() = 0;
	//
	//	update with the host object
	//
	virtual bool onUpdate(const int& nElapse) = 0;
	//
	//	response on a gene event, this is the only way gene communicate with outside logic
	//	Note that gene can received a event only after he register it.
	//	this the only way, gene get information from outside world,
	//	in fact, gene is not an open man, he only trust his host, and only handle 
	//	those events that register to his host before.
	//
	virtual void onEvent(IEvt& evt) = 0;

};

#endif